package com.xinweisi.dataserver.module.memberdata.memberbehavior;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xinweisi.dataserver.common.domain.PageResultDTO;
import com.xinweisi.dataserver.common.domain.ResponseDTO;
import com.xinweisi.dataserver.module.memberdata.memberbehavior.domain.dto.MemberBehaviorQueryDTO;
import com.xinweisi.dataserver.module.memberdata.memberbehavior.domain.entity.MemberBehaviorVO;
import com.xinweisi.dataserver.util.SmartPageUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class MemberBehaviorService {
    @Autowired
    private MemberBehaviorDao memberBehaviorDao;
    /**
     * 分页获取会员行为
     *
     * @param queryDTO
     * @return
     */
    public ResponseDTO<PageResultDTO<MemberBehaviorVO>> getMemberBehavior(MemberBehaviorQueryDTO queryDTO) {
        Page page = SmartPageUtil.convert2QueryPage(queryDTO);
        /*if(queryDTO.getAccount() != null){
            queryDTO.setAccount(queryDTO.getAccount().toLowerCase());
        }*/
        sql(queryDTO.getDBNameList());
        List<MemberBehaviorVO> entityList = memberBehaviorDao.selectMemberBehaviorList(queryDTO);
        PageResultDTO<MemberBehaviorVO> pageResultDTO = SmartPageUtil.convert2PageResult(page, entityList, MemberBehaviorVO.class);
        return ResponseDTO.succData(pageResultDTO);
    }

    /**
     * 拼接会员行为日志
     * @param dbNameList
     * @return
     */
    private String sql(List<String> dbNameList){
        StringBuffer sql = new StringBuffer();
        return sql.toString();
    }
}
